﻿namespace TanHungViet.Web.Models
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    using log4net;

    public class ParameterRepository
    {
        private static ILog _logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private DBTanHungVietEntities _db;

        public ParameterRepository(DBTanHungVietEntities entity)
        {
            _db = entity;
        }

        public string GetParamValue(string paramName)
        {
            var param = _db.Param.FirstOrDefault(b => b.ParamName == paramName);
            if (param != null)
                return param.ParamValue;
            else
                return string.Empty;
        }

        public void SetParamValue(string paramName, string paramValue)
        {
            var param = _db.Param.FirstOrDefault(b => b.ParamName == paramName);
            if (param != null)
            {
                param.ParamValue = paramValue;
                _db.SaveChanges();
            }
        }
    }
}
